package com.swt.gap.controller;

import com.swt.gap.model.entity.OntologyNode;
import com.swt.gap.model.vo.CountPropertyVO;
import com.swt.gap.model.vo.LabelProperty;
import com.swt.gap.model.vo.element.EventElementVO;
import com.swt.gap.model.vo.ontology.ListLevelNodeVO;
import com.swt.gap.model.vo.ontology.OntologyNodeVO;
import com.swt.gap.service.OntologyNodeService;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Set;

/**
 * 请填写说明
 *
 * @author sx
 * @date 2020/5/31 21:26
 */
@Api(tags = "901. 本体节点，即图谱配置中节点部分")
@RestController
@RequestMapping("/ontology/node")
@Slf4j
public class OntologyNodeController {

    private final OntologyNodeService ontologyNodeService;

    public OntologyNodeController(OntologyNodeService ontologyNodeService) {
        this.ontologyNodeService = ontologyNodeService;
    }

    @GetMapping("/level-node")
    @ApiOperation(value = "获取层级实体列表", notes = "获取层级实体列表")
    @ApiResponses({@ApiResponse(code = 200, message = "ok", response = ListLevelNodeVO.class, responseContainer = "List")})
    public ResponseEntity<List<ListLevelNodeVO>> listLevelNode() {
        return ResponseEntity.ok(ontologyNodeService.listLevelNode());
    }

    @GetMapping("/count-property")
    @ApiOperation(value = "获取节点统计的属性", notes = "根据任务id，获取节点统计的属性")
    @ApiResponses({@ApiResponse(code = 200, message = "ok", response = CountPropertyVO.class, responseContainer = "List")})
    public ResponseEntity<List<CountPropertyVO>> listNodeCountProperty(@RequestParam Integer taskId) {
        return  ResponseEntity.ok(ontologyNodeService.listNodeCountProperty(taskId));
    }

    @GetMapping("/event-node-property")
    @ApiOperation(value = "获取事件节点的属性", notes = "根据任务id，获取事件节点的属性")
    @ApiResponses({@ApiResponse(code = 200, message = "ok", response = LabelProperty.class, responseContainer = "List")})
    public ResponseEntity<List<LabelProperty>> listEventNodeProperty(@RequestParam Integer taskId) {
        return  ResponseEntity.ok(ontologyNodeService.listEventNodeProperty(taskId));
    }

    @GetMapping("/event-node-element")
    @ApiOperation(value = "根据事件节点id获取事件要素以及关联节点", notes = "根据事件节点id获取事件要素,即事件节点的属性以及关联节点")
    @ApiImplicitParam(name = "nodeId", dataType = "int",paramType = "query", value = "事件节点id")
    @ApiResponses({@ApiResponse(code = 200, message = "ok", response = EventElementVO.class, responseContainer = "List")})
    public ResponseEntity<List<EventElementVO>> listEventElementsAndRelNodeById(@RequestParam Integer nodeId){
        return ResponseEntity.ok(ontologyNodeService.listEventElementsAndRelNodeById(nodeId));
    }

    @GetMapping("/event-element")
    @ApiOperation(value = "根据事件节点id获取事件要素，仅要素", notes = "根据事件节点id获取事件要素,即事件节点的属性")
    @ApiImplicitParam(name = "nodeId", dataType = "int",paramType = "query", value = "事件节点id")
    @ApiResponses({@ApiResponse(code = 200, message = "ok", response = EventElementVO.class, responseContainer = "List")})
    public ResponseEntity<List<EventElementVO>> listEventElementsById(@RequestParam Integer nodeId){
        return ResponseEntity.ok(ontologyNodeService.listEventElementsById(nodeId));
    }

    @GetMapping("recommend-node")
    @ApiOperation(value = "推荐节点", notes = "推荐节点")
    @ApiImplicitParam(name = "header", dataType = "int",paramType = "query", value = "表头")
    @ApiResponses({@ApiResponse(code = 200, message = "ok", response = OntologyNodeVO.class, responseContainer = "List")})
    public ResponseEntity<Set<OntologyNodeVO>> listRecommendNodes(@RequestParam List<String> header){
        return ResponseEntity.ok(ontologyNodeService.listRecommendNodes(header));
    }

    @GetMapping("/first-level-node")
    @ApiOperation(value = "获取一级节点类型列表", notes = "获取一级节点类型列表")
    @ApiResponses({@ApiResponse(code = 200, message = "ok", response = OntologyNode.class, responseContainer = "List")})
    public ResponseEntity<List<OntologyNode>> listFirstLevelNode() {
        return ResponseEntity.ok(ontologyNodeService.listFirstLevelNode());
    }

    @GetMapping("/children-node")
    @ApiOperation(value = "获取子级节点类型列表", notes = "获取子级节点类型列表")
    @ApiImplicitParam(name = "nodeId", dataType = "int",paramType = "query", value = "本体节点id")
    @ApiResponses({@ApiResponse(code = 200, message = "ok", response = OntologyNode.class, responseContainer = "List")})
    public ResponseEntity<List<OntologyNode>> listChildrenNodesById(@RequestParam Integer nodeId) {
        return ResponseEntity.ok(ontologyNodeService.listChildrenNodesById(nodeId));
    }
}
